package com.kkyy.findmusic.controller;

import com.kkyy.common.utils.R;
import com.kkyy.findmusic.entity.NewMusicEntity;
import com.kkyy.findmusic.service.NewMusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/newmusic")
public class NewMusicController {
    @Autowired
    NewMusicService newMusicService;

    // 查询最新音乐(前端)
    @RequestMapping("/songs")
    public R getSongs() {
        List<NewMusicEntity> songs = newMusicService.getSongs();
        return R.ok().put("data", songs);
    }

    // 点击分类列表查询最新音乐(前端)
    @RequestMapping("/songsbytype")
    public R getSongsByType(Integer type) {
        List<NewMusicEntity> songs = newMusicService.getSongsByType(type);
        return R.ok().put("data", songs);
    }

    // 远程调用查询到最新的音乐才能收藏
    @RequestMapping("/getOneBySongsId")
    NewMusicEntity getOneBySongsId(@RequestParam("songsId") Integer songsId) {
        return newMusicService.getOneBySongsId(songsId);
    }
}